package com.itheima.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;

public class StreamDemo02 {
    public static void main(String[] args) {
        //单列集合
        ArrayList<String> arrayList = new ArrayList<>();
        Collections.addAll(arrayList,"张三","张三丰","张翠山","王二麻子","张良","谢广坤");
//        arrayList.stream().filter(s -> s.startsWith("张")).filter(s -> s.length()==3)
//                .forEach(s -> System.out.println(s));
        arrayList.stream().limit(3).forEach(s -> System.out.print(s+"\t"));
        System.out.println();
        arrayList.stream().skip(3).forEach(s -> System.out.print(s+"\t"));
        System.out.println();

        ArrayList<String> arrayList2 = new ArrayList<>();
        Collections.addAll(arrayList2,"张三","张三丰","张翠山","王二麻子","张良","谢广坤");

        Stream.concat(arrayList.stream(), arrayList2.stream())
                .forEach(s -> System.out.println(s));


        ArrayList<String> arrayList3 = new ArrayList<>();
        Collections.addAll(arrayList3,
                "张三","张三丰","张翠山","王二麻子","张良","谢广坤","谢广坤","谢广坤","谢广坤");
        arrayList3.stream().distinct().forEach(s -> System.out.println(s));

    }
}
